using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;


namespace Wandor
{
	public partial class FinishWindow : Form
	{
		private readonly Uri _url;
		public FinishWindow(MatchCollection matches, Uri maplink)
		{
			InitializeComponent();
			otherResults.Text += Environment.NewLine;
			
			var distance = matches[0].Groups["distance"].ToString();
			var unit = matches[0].Groups["unit"].ToString();
			
			if(unit != "km")
			{
				// warn the user if the unit is not in kilometres.
				// it's not intended to have non-kilometre distances in Hungary.
				MessageBox.Show("A távolság nem kilóméterben van! Ez nagy valószínűséggel egy szoftver hiba, kérem jelentse!", "Figyelmeztetés!", MessageBoxButtons.OK);
			}
			
			resultLabel.Text += distance + " " + unit;
			
			for(int i = 1; i < matches.Count; ++i)
			{
				otherResults.Text += Environment.NewLine + matches[i].Groups["distance"].ToString() + " " + matches[i].Groups["unit"].ToString();
			}
			
			_url = maplink;
			
			
			
		}
		
		public void viewMap_Click(object sender, EventArgs ea)
		{
			System.Diagnostics.Process.Start(_url.ToString());
			
		}
	}
}
